Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.UIName = undefined;
var $2ToastUI = require("ToastUI");
var $2BundleManager = require("BundleManager");
var $2ADManager = require("ADManager");
var $2pvzChannel = require("pvzChannel");
(function (e) {
  e.MainUI = "MainUI";
  e.LevelUI = "LevelUI";
  e.PassUI = "PassUI";
  e.TipPanelUI = "TipPanelUI";
  e.TipPanelUI2 = "TipPanelUI2";
  e.SettingUI = "SettingUI";
  e.SelectUI = "SelectUI";
  e.ShareUI = "ShareUI";
  e.GuideUI = "GuideUI";
})(exports.UIName || (exports.UIName = {}));
var def_UIManager = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this.uiList = {};
    this.uiRoot = null;
    this.showBannerUIMap = new Map([["PauseUI", 1], ["Pause1UI", 1]]);
    this.nativeArrMap = new Map([["DrawUI", 1], ["BossSelectUI", 1], ["ShopUI", 1], ["UpgradeUI", 1], ["PauseUI", 1], ["Pause1UI", 1], ["SignUI", 1], ["TaskUI", 1], ["OnlineRewardUI", 1]]);
    this.uiRoot = cc.find("Canvas/UI");
  }
  babel_createClass(_ctor, [{
    key: "openUI",
    value: function openUI(e, t, a) {
      $2ADManager.default.instance.hideNative();
      if (this.uiList[e]) {
        return this.uiList[e];
      }
      a || (a = this.uiRoot);
      var n;
      var _l4 = $2BundleManager.default.instance.getBundleRes("Prefab", "UIPrefab/" + e, cc.Prefab);
      if (_l4) {
        n = cc.instantiate(_l4);
        a.addChild(n);
        t && (n.zIndex = t);
      }
      this.uiList[e] = n;
      console.log("Openuiname==", e);
      if (this.showBannerUIMap.has(e)) {
        if ($2pvzChannel.pvzChannel.instance().channel.indexOf("wx") >= 0) {
          $2pvzChannel.pvzChannel.instance().showNative(null, null, "nativeBanner");
        } else {
          $2pvzChannel.pvzChannel.instance().showBanner();
        }
      }
      if (this.nativeArrMap.has(e) && $2pvzChannel.pvzChannel.instance().channel.indexOf("wx") >= 0) {
        $2pvzChannel.pvzChannel.instance().showNative(null, null, "nativeArr1");
        $2pvzChannel.pvzChannel.instance().showNative(null, null, "nativeArr2");
      }
      return n;
    }
  }, {
    key: "closeUI",
    value: function closeUI(e) {
      $2ADManager.default.instance.hideNative();
      console.log("Closeuiname--", e);
      if (null != this.uiList[e]) {
        this.uiList[e].destroy();
        delete this.uiList[e];
      }
      if (this.showBannerUIMap.has(e)) {
        if ($2pvzChannel.pvzChannel.instance().channel.indexOf("wx") >= 0) {
          $2pvzChannel.pvzChannel.instance().closeNative("nativeBanner");
        } else {
          $2pvzChannel.pvzChannel.instance().closeBanner();
        }
      }
      if (this.nativeArrMap.has(e) && $2pvzChannel.pvzChannel.instance().channel.indexOf("wx") >= 0) {
        $2pvzChannel.pvzChannel.instance().closeNative("nativeArr1");
        $2pvzChannel.pvzChannel.instance().closeNative("nativeArr2");
      }
    }
  }, {
    key: "showUI",
    value: function showUI(e, t) {
      if (this.uiList[e]) {
        this.uiList[e].active = true;
      } else {
        _ctor.instance.openUI(e, t);
      }
    }
  }, {
    key: "hideUI",
    value: function hideUI(e) {
      this.uiList[e] && (this.uiList[e].active = false);
    }
  }, {
    key: "showToast",
    value: function showToast(e) {
      if (this.uiList.ToastUI) {
        this.uiList.ToastUI.getComponent($2ToastUI.default).showToast(e);
      } else {
        this.openUI("ToastUI", 999).getComponent($2ToastUI.default).showToast(e);
      }
    }
  }], [{
    key: "instance",
    get() {
      this._instance || (this._instance = new _ctor());
      return this._instance;
    }
  }]);
  return _ctor;
}();
exports.default = def_UIManager;
def_UIManager._instance = null;